package com.ssm.service.impl;

import com.ssm.entity.ElcInfotype;
import com.ssm.dao.ElcInfotypeDao;
import com.ssm.service.ElcInfotypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ElcInfotype)表服务实现类
 *
 * @author makejava
 * @since 2021-06-01 10:37:32
 */
@Service("elcInfotypeService")
public class ElcInfotypeServiceImpl implements ElcInfotypeService {
    @Resource
    private ElcInfotypeDao elcInfotypeDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ElcInfotype queryById(Integer id) {
        return this.elcInfotypeDao.queryById(id);
    }

    @Override
    public boolean queryByTypename(String typename) {
        return this.elcInfotypeDao.queryByTypename(typename)==null;
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ElcInfotype> queryAllByLimit(int offset, int limit) {
        return this.elcInfotypeDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<ElcInfotype> queryAll(ElcInfotype elcInfotype) {
        return this.elcInfotypeDao.queryAll(elcInfotype);
    }

    @Override
    public List<ElcInfotype> queryAllByUserId(ElcInfotype elcInfotype) {
        return elcInfotypeDao.queryAllByUserId(elcInfotype);
    }

    /**
     * 新增数据
     *
     * @param elcInfotype 实例对象
     * @return 实例对象
     */
    @Override
    public ElcInfotype insert(ElcInfotype elcInfotype) {
        this.elcInfotypeDao.insert(elcInfotype);
        return elcInfotype;
    }

    /**
     * 修改数据
     *
     * @param elcInfotype 实例对象
     * @return 实例对象
     */
    @Override
    public ElcInfotype update(ElcInfotype elcInfotype) {
        this.elcInfotypeDao.update(elcInfotype);
        return this.queryById(elcInfotype.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.elcInfotypeDao.deleteById(id) > 0;
    }

    @Override
    public boolean deleteByIds(Integer[] ids) {
        for (Integer id:ids){
            deleteById(id);
        }
        return true;
    }


}
